<template>
  <div class="">
    <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
      <el-tab-pane label="基坑监控" name="1">
        <FoundationDitch class="content-wrap" ref="FoundationDitchRef" />
      </el-tab-pane>
      <el-tab-pane label="设备列表" name="2">
        <dos class="content-wrap" ref="dosRef" />
      </el-tab-pane>
    </el-tabs>

    <div class="button_box">
      <el-button type="text" plain icon="el-icon-refresh" @click="onRefreshClick">刷新</el-button>
      <el-button type="text" plain :icon="icon" v-if="activeName == 2">添加设备</el-button>
    </div>
  </div>
</template>

<script>
import httpInterface from "../../util/httpInterface";

export default {
  name: "Foundation",
  components: {
    FoundationDitch: () => import('./foundation/FoundationDitch'),
    dos: () => import('./foundation/dos')
  },
  data() {
    return {
      activeName: '2',
      icon: "el-icon-circle-plus-outline"
    }
  },

  mounted() {
    httpInterface.getUserInfo(() => {
      this.onRefreshClick();
    })
  },

  methods: {
    handleClick() {
      this.onRefreshClick();
    },

    onRefreshClick() {
      switch (this.activeName) {
        case "1":
          this.$nextTick(() => {
            this.$refs.FoundationDitchRef.init();
          })
          break;
        case "2":
          this.$nextTick(() => {
            this.$refs.dosRef.init();
          })
          break;
      }
    }
  }
}
</script>

<style scoped lang="scss">
.content-wrap {
  padding: 80px 20px 20px 20px;
  box-sizing: border-box;
  height: 100vh;
}
</style>
